Fix scroll-to-text-fragment behavior for same-document navigation A same-document navigation to a URL with a text fragment anchor should not scroll the page to the text fragment. The test modified by this CL is meant to test that. However, that behavior was broken by this CL: https://chromium-review.googlesource.com/c/chromium/src/+/2533688 The reason the test hasn't been failing is that it has been checking to see whether the page was scrolled too soon. When a text fragment anchor finds a match, it doesn't scroll the page right away; it schedules a task to scroll the page which runs at rAF timing on the next lifecycle update. This scheduling behavior was added by: https://chromium-review.googlesource.com/c/chromium/src/+/2182992 Just adding requestAnimationFrame to the test caused it to fail; the change to document_loader.cc fixes it. Bug: 1147453 Change-Id: I001a315418f5f8a61ded7d87023740cd366389f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2766287 Reviewed-by: Stefan Zager <szager@chromium.org> Reviewed-by: Joey Arhar <jarhar@chromium.org> Reviewed-by: Nick Burris <nburris@chromium.org> Commit-Queue: Stefan Zager <szager@chromium.org> Cr-Commit-Position: refs/heads/master@{#863893} diff --git a/scroll-to-text-fragment/scroll-to-text-fragment-same-doc.html b/scroll-to-text-fragment/scroll-to-text-fragment-same-doc.html index 3bfd453..ff33952 100644 --- a/scroll-to-text-fragment/scroll-to-text-fragment-same-doc.html +++ b/scroll-to-text-fragment/scroll-to-text-fragment-same-doc.html 
@@ -14,12 +14,13 @@    function checkScroll(resolve) {  let position = 'unknown'; - if (window.scrollY == 0) - position = 'top'; - else if (isInView(document.getElementById('text'))) - position = 'text'; - - resolve(position); + requestAnimationFrame(() => { + if (window.scrollY == 0) + position = 'top'; + else if (isInView(document.getElementById('text'))) + position = 'text'; + resolve(position); + });  }    function runTest() {